<?php 
/**
* A really simple and stupid DB class. Should be replaced with adodb soon.
*
* $Id: DB.php 49 2005-08-04 04:50:34Z vluther $ 				
* @package includes
* @version $Rev: 49 $
* @copyright Copyright &copy; 2000-2007, Linuxpowered, Inc               
* @author Vidyut Luther <vid@linuxpowered.com> 
**/
	class DB
	{
		
		var $_dbuser;
		var $_dbpass; 
		var $_dbname ; 
		var $_dbhost ;
		var $_NumRows ; 
	  var $strError ; 	
		
		function DB()
		{
			$this->_dbuser = null ; 
			$this->_dbpass = null ; 
			$this->_dbname = null ; 
			$this->_dbhost = null ;
      $this->strError = null ;  
		}	
		
		
		function mSetdbUser($dbuser) 
		{
			$this->_dbuser = $dbuser; 
		}
		
		function mSetdbPass($dbpass)
		{
			$this->_dbpass = $dbpass; 
		}
		
		function mSetdbName($dbname)
		{
			$this->_dbname = $dbname;
		}
		
		function mSetdbHost($dbhost)
		{
			$this->_dbhost = $dbhost; 
		}
		
		function mConnect()
		{
			
			$dbhost = $this->_dbhost; 
			$dbname = $this->_dbname; 
			$dbuser = $this->_dbuser; 
			$dbpass = $this->_dbpass ;
			
			/*
			echo "The Vars are: <BR> 
			
			DBNAME = $dbname  <BR>
			DBUSER = $dbuser <BR> 
			DBPASS = $dbpass <BR>
			DBHOST = $dbhost <BR> 
			
			
			";  
			*/
			$conn = mysql_connect("$dbhost", "$dbuser", "$dbpass") or die ("Unable to connect to database.");
			mysql_select_db("$dbname") or die ("Unable to select database.");
			
			return $conn ; 
		}
		
		function mRun($sql) {
			$rs = mysql_query($sql) ; 	
			
            /* Set other properties of the Db now */
		  if($rs) { 	
			  $this->mSetRsCount($rs) ;
      }
			return $rs; 
		}
		
		
		function mInsert($sql) 
    {
			$rs = mysql_query($sql) ; 	
      if(!$rs) {
        $this->strError = mysql_error(); 
        return false; 
      } 
      
      return true; 
		}
		
		function mSetRsCount($rs)
		{
			$count = mysql_num_rows($rs) ;
			$this->_NumRows = $count ; 	
		}
		
		
	  function mGetNumRows()
    {
      return $this->_NumRows; 
    }
		
		
		
		
		
  function Execute($sql,$type)
  {
    $rs = mysql_query($sql); 
    if($rs) { 
      return true; 
    } else {
      return false; 
    }
  }
		
		
		
		
		
		
		
		
		
		
	}






?>
